<?php

namespace Beerus\Modules\DesignerService\Actions;

use Doraemon\model\DesignerService\ServiceContentRecord;
use Encore\Admin\Actions\RowAction;
use Illuminate\Http\Request;

class Remark extends RowAction
{
	public $name = '备注';

	public function handle($id, Request $request) {
		$params = $request->all();

		$result = ServiceContentRecord::update([
			'remark' => $params['remark'],
		], [
			'id' => $id
		]);

		if ($result) {
			return $this->response()->success('操作成功(＾－＾)V')->refresh();
		}else{
			return $this->response()->success('操作失败,请稍后重试o(TωT)o');
		}
	}

	public function retrieveModel(Request $request)
	{
		if (!$key = $request->get('_key')) {
			return false;
		}

		return $key;
	}

	public function form()
	{
		$this->textarea('remark', '备注信息')->setWidth(4, 4);
	}
}
